package com.blog.admin.service;

import com.blog.admin.mapper.BlogLinkMapper;
import com.blog.admin.vo.BlogLinkVO;
import com.blog.vo.PageVO;
import com.blog.common.PageHelperLog;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author tangqj
 * @Description 友情链接
 * @create 2020/2/18 14:35
 */
@Service
@Transactional
public class BlogLinkService {
    @Autowired
    BlogLinkMapper  blogLinkMapper;

    /**
     * 分页获取友情链接
     * @param page
     * @return
     */
    @PageHelperLog(desc = "msg")
    public PageInfo<BlogLinkVO> getBlogLink(PageVO page,BlogLinkVO blogLinkVO) {
        List<BlogLinkVO> list = blogLinkMapper.getBlogLink(blogLinkVO);
        PageInfo<BlogLinkVO> pageRest = new PageInfo<BlogLinkVO>(list);
        return pageRest;
    }

    /**
     * 插入友情链接
     * @param blogLinkVO
     * @return
     */
    public boolean insertBlogLink(BlogLinkVO blogLinkVO) {
        int result = blogLinkMapper.insertBlogLink(blogLinkVO);
        return result>0?true:false;
    }

    /**
     * 修改友情链接
     * @param blogLinkVO
     * @return
     */
    public boolean updateBlogLink(BlogLinkVO blogLinkVO) {
        int result = blogLinkMapper.updateBlogLink(blogLinkVO);
        return result>0?true:false;
    }

    /**
     * 删除友情链接
     * @param id
     * @return
     */
    public boolean deleteBlogLinkById(String id) {
        int result = blogLinkMapper.deleteBlogLinkById(id);
        return result>0?true:false;
    }


}
